using System.IO;
using System.Net;

namespace BuildBox.Core.Server.Adapters
{
    public interface IHttpListenerResponseAdapter
    {
        int StatusCode { get; set; }
        string StatusDescription { get; set; }
        Stream OutputStream { get; }
        long ContentLength64 { get; set; }
        string ContentType { get; set; }
        IConfiguration Configuration { get; }
    }

    public class HttpListenerResponseAdapter : IHttpListenerResponseAdapter
    {
        private readonly HttpListenerResponse _response;

        public HttpListenerResponseAdapter(HttpListenerResponse response, IConfiguration configuration)
        {
            _response = response;
            Configuration = configuration;
        }

        public int StatusCode
        {
            get { return _response.StatusCode; }
            set { _response.StatusCode = value; }
        }

        public string StatusDescription
        {
            get { return _response.StatusDescription; }
            set { _response.StatusDescription = value; }
        }

        public Stream OutputStream
        {
            get { return _response.OutputStream; }
        }

        public long ContentLength64
        {
            get { return _response.ContentLength64; }
            set { _response.ContentLength64 = value; }
        }

        public string ContentType
        {
            get { return _response.ContentType; }
            set { _response.ContentType = value; }
        }

        public IConfiguration Configuration { get; private set; }
    }
}